/**
 * Created by wm123 on 2017/6/27.
 */
const extend = require('extend');

const { Role } = require('board-game');

class GuessDrawRole extends Role {
    constructor(server, room, player, team, index) {
        super(server, room, player, team, index);
        this.comment = false;
    }
    drawDown(point) {
        this.game.drawDown(this, point);
    }
    drawUp(point) {
        this.game.drawUp(this, point);
    }
    drawMove(point) {
        this.game.drawMove(this, point);
    }
    drawMoves(points) {
        this.game.drawMoves(this, points);
    }
    undo() {
        this.game.undo(this);
    }
    empty() {
        this.game.empty(this);
    }
    setColor(color) {
        this.game.setColor(this, color);
    }
    setSize(size) {
        this.game.setSize(this, size);
    }
    setBackground(background) {
        this.game.setBackground(this, background);
    }
    good() {
        this.game.good(this);
    }
    bad() {
        this.game.bad(this);
    }
    over(win, game) {
        let result = super.over(win, game);
        result.scores = game.groups.map((group, groupIndex) => ({ role: group.roles.map(role => role.player.name).join(','), score: game.board.scores[groupIndex]}));
        return result;
    }
    get data() {
        return extend(true, super.data, {
            comment: this.comment
        });
    }
}

module.exports = GuessDrawRole;